﻿<?php
include "connect/connect_dsccmis.php";
$sql = "select max(upddte) as last_upddte_event from gis_event";
$rs = mysql_query($sql);
$row=mysql_fetch_array($rs);
$last_upddte_event=$row["last_upddte_event"];
$sql = "select max(perupddte) as last_upddte_victim from gis_victim";
$rs = mysql_query($sql);
$row=mysql_fetch_array($rs);
$last_upddte_victim=$row["last_upddte_victim"];
mysql_close($c);
?>
<script type="text/javascript">
// Global Variable -------------------------------------------------
	var chkuse_date = "";
	var date_start = "";
	var date_end = "";
	var chkuse_prov = "";
	var	 OccNumber              = "";
	var  occNumber1             = "";
	var  occNumber2             = "";
	var  occNumber3             = "";
	var  occNumber4             = "";
	var  chkbox_project         = "";
	var  chkbox_project1        = "";
	var  chkbox_project2        = "";
	var  chkbox_project3        = "";
	var  chkbox_project4        = "";
	var  chkbox_project5        = "";
	var	OccProvince	            = "";
	var occProvince90           = "";
	var occProvince94           = "";
	var occProvince95           = "";
	var occProvince96           = "";
	var occProvince00           = "";
	var chk_occ                 = "";
	var chk_occ1                = "";
	var chk_occ2                = "";
	var chk_occ3                = "";
	var chk_occ4                = "";
	var chk_occ5                = "";
	var chk_occ6                = "";
	var	chk_occ7                = "";
	var chk1	= "";
	var chk2	= "";
	var chk3	= "";
	var chk4	= "";
	var chk5	= "";
	var chkbox90 = "";
	var chkbox94 = "";
	var chkbox95 = "";
	var chkbox96 = "";
	var chkbox00 = "";
	var chkuse_cause = "";
	var chkbox_cause1 = "";
	var chkbox_cause2 = "";
	var chkbox_cause0 = "";
	var cond_cause = "";
	var chkuse_evntyp = "";
	var chkbox_evntyp1 = "";
	var chkbox_evntyp2 = "";
	var chkbox_evntyp3 = "";
	var chkbox_evntyp4 = "";
	var cond_evntyp = "";
	var user_type = "1";
	var gpoint="";
	var map;
	var circle = null;
    var circle2 = null;
    var map;
    var geocoder;
	var ggg=gpoint/2;
    var iconRed = new GIcon(); 
    iconRed.image = 'iconfile/circlered.png';
    /* iconRed.iconSize = new GSize(gpoint, gpoint);
   // iconRed.shadowSize = new GSize(30, 30);
     iconRed.iconAnchor = new GPoint(gpoint/2, gpoint/2);
    iconRed.infoWindowAnchor = new GPoint(gpoint, gpoint/2);
	 */
	var iconBlue = new GIcon(); 
    iconBlue.image = 'iconfile/circleBlue.png';
    /* iconBlue.iconSize = new GSize(gpoint, gpoint);
    //iconBlue.shadowSize = new GSize(30, 30);
     iconBlue.iconAnchor = new GPoint(ggg, ggg);
    iconBlue.infoWindowAnchor = new GPoint(ggg, ggg); */
	
	

	//var customIcons = [];
    //customIcons["ปิด"] = iconBlue;
    //customIcons["เปิด"] = icongreen;
	//customIcons["cross"] = iconx;
    var customIcons = [];
    //customIcons["ปัตตานี"] = iconRed;
	customIcons["2"] = iconBlue;
	customIcons["1"] = iconRed;
	

// end Global Variable ---------------------------------------------

// ------------------ Event timemap --------------------------------
var tm;
function onLoad(kml_fname) { // function of timemap
    tm = TimeMap.init({ //ฟังก์ชั่นเริ่มต้นแสดง map
        mapId: "map",  // Id of map div element (required)
        timelineId: "timeline",  // Id of timeline div element (required) 
        options: {
            eventIconPath: "images/"
        },
        datasets: [
            {
                title: "Event in Deep South Provinces",
                theme: "red",
                type: "kml",     // Data to be loaded in KML - must be a local URL
                options: {
					url: "kml/"+kml_fname// KML file to load
					//url: "kml/kenya1.kml" // KML file to load
                }
            }
        ],
        bandInfo: [
            {
               width:          "85%", 
               intervalUnit:   Timeline.DateTime.DAY, 
		       intervalPixels: 210
            },
            {
               width:          "15%", 
               intervalUnit:   Timeline.DateTime.WEEK, 
		       intervalPixels: 150,
               showEventText:  false,
               trackHeight:    0.2,
               trackGap:       0.2
            }
        ]
    });
}
// show or hidden for event, victim or project -------------------
function ShowHiddenCondition(cas){
	if(cas==3){
		var ele = document.getElementById('cond_case3');
		ele.style.display="block";
		var ele = document.getElementById('cond_case12');
		ele.style.display="none";
		document.getElementById("timemap").innerHTML = "<divid=\"mapcontainer\"><div id=\"map\"></div></div>";
		var map = new GMap(document.getElementById("map"));
		//document.getElementById("date_start").value = "<?=getDateTimeYMD($last_upddte_victim)?>";
			//document.getElementById("date_end").value = "<?=getDateTimeYMD($last_upddte_victim)?>";
			//document.getElementById("addr_type").innerHTML = "";
			//document.getElementById("last_update").innerHTML = "(ปรับปรุงล่าสุด <?=getDateTimeDMY($last_upddte_victim)?>)";
			//document.getElementById("numevent_all").innerHTML = "";
			document.getElementById("chkuse_prov")
			document.getElementById("numevent").innerHTML = "";
			document.getElementById("timemap").innerHTML = "<div id=\"mapcontainer\"><div id=\"map\"></div></div>";
			map = new GMap(document.getElementById("map"));
			map.addControl(new GLargeMapControl());
 			//map.addControl(new GLargeMapControl3D());
     		map.addControl(new GMapTypeControl());
			map.setCenter(new GLatLng(6.710982,101.299438), 7);
	 		//map.setCenter(new GLatLng(13.785447,100.590976),6, G_NORMAL_MAP);
			
		
  	}else{
		var ele = document.getElementById('cond_case3');
		ele.style.display="none";
		var ele = document.getElementById('cond_case12');
		ele.style.display="block";
		if(cas==2){
			document.getElementById("date_start").value = "<?=getDateTimeYMD($last_upddte_victim)?>";
			document.getElementById("date_end").value = "<?=getDateTimeYMD($last_upddte_victim)?>";
			document.getElementById("addr_type").innerHTML = "ที่อยู่ตามทะเบียนบ้าน";
			document.getElementById("last_update").innerHTML = "(ปรับปรุงล่าสุด <?=getDateTimeDMY($last_upddte_victim)?>)";
			document.getElementById("numevent_all").innerHTML = "";
			document.getElementById("numevent").innerHTML = "";
			document.getElementById("timemap").innerHTML = "<div id=\"mapcontainer\"><div id=\"map\"></div></div>";
			map = new GMap(document.getElementById("map"));
			map.addControl(new GLargeMapControl());
 			//map.addControl(new GLargeMapControl3D());
     		map.addControl(new GMapTypeControl());
	 		map.setCenter(new GLatLng(13.785447,100.590976),6, G_NORMAL_MAP);
		}else{
			document.getElementById("date_start").value = "<?=getDateTimeYMD($last_upddte_event)?>";
			document.getElementById("date_end").value = "<?=getDateTimeYMD($last_upddte_event)?>";
			document.getElementById("addr_type").innerHTML = "ที่เกิดเหตุ";
			document.getElementById("last_update").innerHTML = "(ปรับปรุงล่าสุด <?=getDateTimeDMY($last_upddte_event)?>)";
			document.getElementById("numevent_all").innerHTML = "";
			document.getElementById("numevent").innerHTML = "";
			document.getElementById("timemap").innerHTML = "<div id=\"timelinecontainer\"><div id=\"timeline\"></div></div><div id=\"mapcontainer\"><div id=\"map\"></div></div>";
			//auto get first and current date
			//document.formcondition.date_start.value =getMonthNowFixDate("01");
			//document.formcondition.date_end.value = getDateNow();
			map = new GMap(document.getElementById("map"));
			//map.addControl(new GLargeMapControl());
     		//map.addControl(new GMapTypeControl());
	 		map.setCenter(new GLatLng(13.785447,100.590976),6, G_NORMAL_MAP);
			checkDataset();
		}
	}
}

// end show or hidden for event, victim or project -------------------
// show or hidden for condition of event and victim -------------------
function changeUseCause(){
	if(document.getElementById("chkuse_cause").checked){
		document.formcondition.chkbox_cause1.disabled = false;
		document.formcondition.chkbox_cause2.disabled = false;
		document.formcondition.chkbox_cause0.disabled = false;
	}else{
		document.formcondition.chkbox_cause1.disabled = true;
		document.formcondition.chkbox_cause2.disabled = true;
		document.formcondition.chkbox_cause0.disabled = true;
	}
}
function changeUseType(){
	if(document.getElementById("chkuse_evntyp").checked){
		document.formcondition.chkbox_evntyp1.disabled = false;
		document.formcondition.chkbox_evntyp2.disabled = false;
		document.formcondition.chkbox_evntyp3.disabled = false;
		document.formcondition.chkbox_evntyp4.disabled = false;
	}else{
		document.formcondition.chkbox_evntyp1.disabled = true
		document.formcondition.chkbox_evntyp2.disabled = true;
		document.formcondition.chkbox_evntyp3.disabled = true;
		document.formcondition.chkbox_evntyp4.disabled = true;
	}
}
function changeUseProv(){
	if(document.getElementById("chkuse_prov").checked){
		document.formcondition.chkbox90.disabled = false;
		document.formcondition.chkbox94.disabled = false;
		document.formcondition.chkbox95.disabled = false;
		document.formcondition.chkbox96.disabled = false;
		document.formcondition.chkbox00.disabled = false;
	}else{
		document.formcondition.chkbox90.disabled = true;
		document.formcondition.chkbox94.disabled = true;
		document.formcondition.chkbox95.disabled = true;
		document.formcondition.chkbox96.disabled = true;
		document.formcondition.chkbox00.disabled = true;
	}
}
/* function changeUseCause2(){
	if(document.getElementById("chkbox_project").checked){
		document.formcondition.chkbox_project1.disabled = false;
		document.formcondition.chkbox_project2.disabled = false;
		document.formcondition.chkbox_project3.disabled = false;
		document.formcondition.chkbox_project4.disabled = false;
		document.formcondition.chkbox_project5.disabled = false;
	}else{
		document.formcondition.chkbox_project1.disabled = true;
		document.formcondition.chkbox_project2.disabled = true;
		document.formcondition.chkbox_project3.disabled = true;
		document.formcondition.chkbox_project4.disabled = true;
		document.formcondition.chkbox_project5.disabled = true;

	}
	
} */
/* function occProvince(){
	if(document.getElementById("OccProvince").checked){
	document.formcondition.occProvince90.disabled = false;
	document.formcondition.occProvince94.disabled = false;
	document.formcondition.occProvince95.disabled = false;
	document.formcondition.occProvince96.disabled = false;
	}else{
		document.formcondition.occProvince90.disabled =true;
	    document.formcondition.occProvince94.disabled =true;
	    document.formcondition.occProvince95.disabled =true;
	    document.formcondition.occProvince96.disabled =true;
	
	}
} */
/* function occType(){
	if(document.getElementById("chk_occ").checked){
		document.formcondition.chk_occ1.disabled = false;
		document.formcondition.chk_occ2.disabled = false;
		document.formcondition.chk_occ3.disabled = false;
		document.formcondition.chk_occ4.disabled = false;
		document.formcondition.chk_occ5.disabled = false;
		document.formcondition.chk_occ6.disabled = false;
		document.formcondition.chk_occ7.disabled = false;
	}else{
		document.formcondition.chk_occ1.disabled =true;
	    document.formcondition.chk_occ2.disabled =true;
	    document.formcondition.chk_occ3.disabled =true;
	    document.formcondition.chk_occ4.disabled =true;
		document.formcondition.chk_occ5.disabled =true;
		document.formcondition.chk_occ6.disabled =true;
		document.formcondition.chk_occ7.disabled =true;
	
	}
} */
	// function occNumber(){
	// if(document.getElementById("OccNumber").checked){
		// document.formcondition.occNumber1.disabled = false;
		// document.formcondition.occNumber2.disabled = false;
		// document.formcondition.occNumber3.disabled = false;
		// document.formcondition.occNumber4.disabled = false;
	// }else{
		// document.formcondition.occNumber1.disabled =true;
	    // document.formcondition.occNumber2.disabled =true;
	    // document.formcondition.occNumber3.disabled =true;
	    // document.formcondition.occNumber4.disabled =true;
	
	// }
	// }
	 function createMarker(point, name, address, type,age,count,surnme,prenme,count2, count3 ,count4, count5 ,count6 ,count22 ,count33 ,count44,count55,count66,count6868,countGis) {
 //alert(type);
 gpoint=count;
      var marker = new GMarker(point, customIcons[name]);
	  var num="";
	  
      var html = "	  <table width=446 border=1>                                  "+
"	  <tr>                                                        "+
"    <td colspan=3><div align=center><strong>"+age+"</strong></div></td>                "+
"  </tr>                                                          "+
"  <tr>                                                           "     +
"    <td width=253 rowspan=2><div align=center>รายการ</div></td>    "  +
"    <td colspan=2><div align=center>จำนวน(คน)</div></td>            "    +
"  </tr>                                                           "      +
"  <tr>                                                            "      +
"    <td width=87><div align=center class=style2>เหตุการณ์ </div></td> "  +
"    <td width=84><div align=center class=style2>ได้รับการเยียวยา</div></td> "  +
"  </tr>                                                           "      +
"  <tr>                                                            "      +
"    <td><span class=style2>เสียชีวิต ณ ที่เกิดเหตุ </span></td>               "       +
"    <td>"+count2+"</td>                                               "      +
"    <td>"+count22+"</td>                                               "      +
"  </tr>                                                           "      +
"  <tr>                                                            "      +
"    <td><span class=style2>บาดเจ็บ(รักษาตัว 8-20 วัน)</span></td>            "        +
"    <td>"+count3+"</td>                                               "      +
"    <td>"+count33+"</td>                                             "      +
"  </tr>                                                           "      +
"  <tr>                                                            "      +
"    <td><span class=style2>บาดเจ็บเล็กน้อย(รักษาตัวไม่เกิน 7 วัน)</span></td>      "        +
"    <td>"+count4+"</td>                                               "      +
"    <td>"+count44+"</td>                                               "      +
"  </tr>                                                           "      +
"  <tr>                                                            "      +
"    <td><span class=style2>บาดเจ็บสาหัส(รักษาตัว 20 วันขึ้นไป</span></td>       "         +
"    <td>"+count5+"</td>                                               "      +
"    <td>"+count55+"</td>                                               "      +
"  </tr>                                                           "      +
"  <tr>                                                            "      +
"    <td><span class=style2>ปลอดภัย/ทรัพย์สินเสียหาย</span></td>            "        +
"    <td>"+count6+"</td>                                               "      +
"    <td>"+count66+"</td>                                               "      +
"  </tr>                                                           "      +
"<tr>                                                             "+
"    <td><div align=center>รวม</div></td>                         "+
"    <td>"+countGis+"</td>                                              "+
"    <td>"+count6868+"</td>                                              "+
"  </tr>                                                          "+
"</table>";
//"   var html = "<table width=200 border=1">  "+
//"  <tr>"+
//"    <td>&nbsp;</td>"+
//"    <td>&nbsp;</td>"+
//"    <td>&nbsp;</td>"+
//"  </tr>"+
//"  <tr>"+
//"    <td>&nbsp;</td>"+
//"    <td>&nbsp;</td>"+
//"    <td>&nbsp;</td>"+
//"  </tr>"+
//"  <tr>"+
//"    <td>&nbsp;</td>"+
//"    <td>&nbsp;</td>"+
//"    <td>&nbsp;</td>"+
//"  </tr>"+
//"  <tr>"+
//"    <td>&nbsp;</td>"+
//"    <td>&nbsp;</td>"+
//"    <td>&nbsp;</td>"+
//"  </tr>"+
//"  <tr>"+
//"    <td>&nbsp;</td>"+
//"    <td>&nbsp;</td>"+
//"    <td>&nbsp;</td>"+
//"  </tr>"+
//"  <tr>"+
//"    <td>&nbsp;</td>"+
//"    <td>&nbsp;</td>"+
//"    <td>&nbsp;</td>"+
//"  </tr>"+
//"  <tr>"+
//"    <td>&nbsp;</td>"+
//"    <td>&nbsp;</td>"+
//"    <td>&nbsp;</td>"+
//"  </tr>"+
//"</table>";


      GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml(html);
      });
	  num=count/2;
		//num=0;
		iconRed.iconSize = new GSize(count, count);
		iconRed.iconAnchor = new GPoint(count/2, count/2);
		iconBlue.iconSize = new GSize(count, count);
		iconBlue.iconAnchor = new GPoint(count/2, count/2);
		iconBlue.infoWindowAnchor = new GPoint(num, num); 
		iconRed.infoWindowAnchor = new GPoint(num, num);  
	  /* if(count>20)
	  {
		iconBlue.iconSize = new GSize(20, 20);
		iconBlue.iconAnchor = new GPoint(10, 10);
		iconRed.iconSize = new GSize(20, 20);
		iconRed.iconAnchor = new GPoint(10, 10);
	  }
	  else if(count>10)
	  {
			iconBlue.iconSize = new GSize(15, 15);
			iconRed.iconSize = new GSize(15, 15);
			iconBlue.iconAnchor = new GPoint(7.5, 7.5);
			iconRed.iconAnchor = new GPoint(7.5, 7.5);
			
	  }
	  else
	  {
	  iconBlue.iconSize = new GSize(10, 10);
	  iconBlue.iconAnchor = new GPoint(5, 5);
	  iconRed.iconSize = new GSize(10, 10);
	  iconRed.iconAnchor = new GPoint(5, 5);
	  } */
		
      return marker;
    }
function createSidebarEntry(marker, name, address) {
  var div = document.createElement('div');
  var html = "<b>ชื่อ : " + name + "</b> <br/>ที่อยู่ : " + address +"<br/> ------------------------------";
  div.innerHTML = html;
  div.style.cursor = 'pointer';
  div.style.marginBottom = '5px';
  GEvent.addDomListener(div, 'click', function() {
    GEvent.trigger(marker, 'click');
  });
  GEvent.addDomListener(div, 'mouseover', function() {
    div.style.backgroundColor = '#eee';
  });
  GEvent.addDomListener(div, 'mouseout', function() {
    div.style.backgroundColor = '#fff';
  });
  return div;
}
function checkDataset2(){
	//alert("dfdfdf");
	var mylat=new Array();
	var mylng=new Array();
	var latlngB=1;
	var countll=0;
	var fname_from_cond2 = "gis_occ";
	var map = new GMap(document.getElementById("map"));
		//document.getElementById("date_start").value = "<?=getDateTimeYMD($last_upddte_victim)?>";
			//document.getElementById("date_end").value = "<?=getDateTimeYMD($last_upddte_victim)?>";
			//document.getElementById("addr_type").innerHTML = "";
			//document.getElementById("last_update").innerHTML = "(ปรับปรุงล่าสุด <?=getDateTimeDMY($last_upddte_victim)?>)";
			//document.getElementById("numevent_all").innerHTML = "";
			document.getElementById("chkuse_prov")
			document.getElementById("numevent").innerHTML = "";
			document.getElementById("timemap").innerHTML = "<div id=\"mapcontainer\"><div id=\"map\"></div></div>";
			map = new GMap(document.getElementById("map"));
 			//map.addControl(new GLargeMapControl3D());
     		map.addControl(new GMapTypeControl());
			map.setCenter(new GLatLng(6.710982,101.299438), 8);
	//alert(fname_from_cond2);
		/* <!--
		if(document.getElementById("OccNumber").checked){	 OccNumber       	 =  "1";	}		else{	 OccNumber       	 =  "";	 				    }
		if(document.getElementById("occNumber1").checked){	 occNumber1      	 =  "1";	}	else{	 occNumber1      	 =  "";	 			    }
		if(document.getElementById("occNumber2").checked){	 occNumber2      	 =  "2";	}	else{	 occNumber2      	 =  "";	 			    }
		if(document.getElementById("occNumber3").checked){	 occNumber3      	 =  "3";	}	else{	 occNumber3      	 =  "";	 			    }
		if(document.getElementById("occNumber4").checked){	 occNumber4      	 =  "4";	}	else{	 occNumber4      	 =  "";				    }
		if(document.getElementById("chkbox_project").checked){	 chkbox_project  	 =  "1";	}else{	 chkbox_project  	 =  "";	 			    }
		if(document.getElementById("chkbox_project1").checked){	 chkbox_project1 	 =  "1";	}else{	 chkbox_project1 	 =  "";		    }
		if(document.getElementById("chkbox_project2").checked){	 chkbox_project2 	 =  "2";	}else{	 chkbox_project2 	 =  "";	 		    }
		if(document.getElementById("chkbox_project3").checked){	 chkbox_project3 	 =  "3";	}else{	 chkbox_project3 	 =  "";	 		    }
		if(document.getElementById("chkbox_project4").checked){	 chkbox_project4 	 =  "4";	}else{	 chkbox_project4 	 =  "";	 			    }
		if(document.getElementById("chkbox_project5").checked){	 chkbox_project5 	 =  "5";	}else{	 chkbox_project5 	 =  "";	    }
		if(document.getElementById("OccProvince").checked){	OccProvince	 		=  "1";	}else{	OccProvince	 =  "";						    }
		if(document.getElementById("occProvince90").checked){	occProvince90    	 =  "90";	}else{	occProvince90    	 =  "";				    }
		if(document.getElementById("occProvince94").checked){	occProvince94    	 =  "94";	}else{	occProvince94    	 =  "";				    }
		if(document.getElementById("occProvince95").checked){	occProvince95    	 =  "95";	}else{	occProvince95    	 =  "";				    }
		if(document.getElementById("occProvince96").checked){	occProvince96    	 =  "96";	}else{	occProvince96    	 =  "";				    }
		if(document.getElementById("chk_occ").checked){	chk_occ          	 =  "1";	}else{	chk_occ          	 =  "";				    }
		if(document.getElementById("chk_occ1").checked){	chk_occ1         	 =  "ขายอาหาร";	}else{	chk_occ1         	 =  "";				    }
		if(document.getElementById("chk_occ2").checked){	chk_occ2         	 =  "ขายของชำ";	}else{	chk_occ2         	 =  "";				    }
		if(document.getElementById("chk_occ3").checked){	chk_occ3         	 =  "ตัดเย็บ";	}else{	chk_occ3         	 =  "";				    }
		if(document.getElementById("chk_occ4").checked){	chk_occ4         	 =  "เลี้ยงสัตว์";	}else{	chk_occ4         	 =  "";				    }
		if(document.getElementById("chk_occ5").checked){	chk_occ5         	 =  "ทำสวน/ปลูกผัก";	}else{	chk_occ5         	 =  "";			    }
		if(document.getElementById("chk_occ6").checked){	chk_occ6         	 =  "ร้านเสริมสวย";	}else{	chk_occ6         	 =  "";			    }
		if(document.getElementById("chk_occ7").checked){	chk_occ7         	 =  "อื่น ๆ";	}else{	chk_occ7         	 =  "";	                }
		 */
		if(document.getElementById("occProvince90").checked){	occProvince90    	 =  "90";	}else{	occProvince90    	 =  "";				    }
		if(document.getElementById("occProvince94").checked){	occProvince94    	 =  "94";	}else{	occProvince94    	 =  "";				    }
		if(document.getElementById("occProvince95").checked){	occProvince95    	 =  "95";	}else{	occProvince95    	 =  "";				    }
		if(document.getElementById("occProvince96").checked){	occProvince96    	 =  "96";	}else{	occProvince96    	 =  "";				    }
		if(document.getElementById("occProvince00").checked){	occProvince00    	 =  "00";	}else{	occProvince00    	 =  "";				    }
	//alert("dfdfdf");
	//fname_from_cond2 = fname_from_cond2+"_"+"OccNumber"+"="+OccNumber+"occNumber1"+"="+occNumber1+"occNumber2"+"="+occNumber2+"occNumber3"+"="+occNumber3+"occNumber4"+"="+occNumber4+"chkbox_project"+"="+chkbox_project+"chkbox_project1"+"="+chkbox_project1+"chkbox_project2"+"="+chkbox_project2+"chkbox_project3"+"="+chkbox_project3+"chkbox_project4"+"="+chkbox_project4+"chkbox_project5"+"="+chkbox_project5+"OccProvince"+"="+OccProvince+"occProvince90"+"="+occProvince90+"occProvince94"+"="+occProvince94+"occProvince95"+"="+occProvince95+"occProvince96"+"="+occProvince96+"chk_occ"+"="+chk_occ+"chk_occ1"+"="+chk_occ1+"chk_occ2"+"="+chk_occ2+"chk_occ3"+"="+chk_occ3+"chk_occ4"+"="+chk_occ4+"chk_occ5"+"="+chk_occ5+"chk_occ6"+"="+chk_occ6+"chk_occ7"+"="+chk_occ7;
	fname_from_cond2 = "OccNumber="+OccNumber+"&occNumber1="+occNumber1+"&occNumber2="+occNumber2+"&occNumber3="+occNumber3+"&occNumber4="+
	occNumber4+"&chkbox_project="+chkbox_project+"&chkbox_project1="+chkbox_project1+"&chkbox_project2="+chkbox_project2+
	"&chkbox_project3="+chkbox_project3+"&chkbox_project4="+chkbox_project4+"&chkbox_project5="+chkbox_project5+"&OccProvince="+
	OccProvince+"&occProvince90="+occProvince90+"&occProvince94="+occProvince94+"&occProvince95="+occProvince95+"&occProvince96="+occProvince96+"&occProvince00="+occProvince00+"&chk_occ="+chk_occ+"&chk_occ1="+chk_occ1+"&chk_occ2="+chk_occ2+"&chk_occ3="+chk_occ3+"&chk_occ4="+chk_occ4+
	"&chk_occ5="+chk_occ5+"&chk_occ6="+chk_occ6+"&chk_occ7="+chk_occ7;
	//fname_from_cond2 = "&OccNumber="+OccNumber;
	
	//alert(fname_from_cond2);
	//user_type = document.getElementById("user_type").value;
	//fname_from_cond = fname_from_cond+"_u"+user_type;
	//fname_from_cond = fname_from_cond.replace(/,/g,'');
	//fname_from_cond2= fname_from_cond+".kml";
	//fname_from_cond2= fname_from_cond2+".kml";
	//fname_from_cond2= "qaz.kml";
	fname_from_cond2= "sample3.php?"+fname_from_cond2;
	//prompt("fname_from_cond2",fname_from_cond2)
	GDownloadUrl(fname_from_cond2, function(data) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
         // var sidebar2 = document.getElementById('sidebar2');
   // sidebar2.innerHTML = '';
    //if (markers.length == 0) {
   if (markers.length == 0) {
      sidebar2.innerHTML = 'No results found.';
      return;
    }

          var bounds = new GLatLngBounds();
		  //var mun="รักยาที่สุด ถ้ารักบัสกดok";
//alert(mun);
          for (var i = 0; i < markers.length; i++) {
		   
		 // alert(getAttribute("lat"));
            var name = markers[i].getAttribute("name");
			var count = markers[i].getAttribute("count");
			var count2 = markers[i].getAttribute("count2");
			var count3 = markers[i].getAttribute("count3");
			var count4 = markers[i].getAttribute("count4");
			var count5 = markers[i].getAttribute("count5");
			var count6 = markers[i].getAttribute("count6");
			var count22 = markers[i].getAttribute("count22");
			var count33 = markers[i].getAttribute("count33");
			var count44 = markers[i].getAttribute("count44");
			var count55 = markers[i].getAttribute("count55");
			var count66 = markers[i].getAttribute("count66");
			var count6868 = markers[i].getAttribute("count6868");
			var countGis = markers[i].getAttribute("countGis");
			var age = markers[i].getAttribute("age");
			var surnme = markers[i].getAttribute("surnme");
			var prenme = markers[i].getAttribute("prenme");
            var address = markers[i].getAttribute("address");
            var type = markers[i].getAttribute("type");
            var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                    parseFloat(markers[i].getAttribute("lng")));
				for(var j =0;j<=countll;j++){
					if(mylat[j]==parseFloat(markers[i].getAttribute("lat"))){
					point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                    parseFloat(markers[i].getAttribute("lng")));
									latlngB=0;
					}
					}
					if(latlngB==1){
					
					countll++;
					mylat[countll]=parseFloat(markers[i].getAttribute("lat"));
					
					}
					else{
					latlngB=1;
					}
				
				
									//  alert(i);
            var marker = createMarker(point, name, address, type,age,count,surnme,prenme,count2, count3 ,count4, count5 ,count6 ,count22 ,count33 ,count44,count55,count66,count6868,countGis);
            map.addOverlay(marker);
	
            //var sidebarEntry = createSidebarEntry(marker, name, address);
           // sidebar2.appendChild(sidebarEntry);
            bounds.extend(point);
          }
        });
		//alert(countll);
	//onLoadMapEvent2(0,fname_from_cond2);
	//alert(fname_from_cond2);
}

// end show or hidden for condition of event and victim -------------------

// check for call event, victim or project map
function checkDataset(){
	// check date
	var d = getDateNow();
	d = d.replace('-','');
	d = d.replace('-','');
	var fname_from_cond = "gis_event"+d;
	//alert(fname_from_cond);
	if(document.getElementById("chkuse_date").checked){
		chkuse_date =  "1";
		fname_from_cond = fname_from_cond+"_"+chkuse_date;
		//alert(fname_from_cond);
		date_start =  document.getElementById("date_start").value;
		date_start = date_start.replace('-','');
		date_start = date_start.replace('-','');
		fname_from_cond = fname_from_cond+date_start;
		//alert(fname_from_cond);
		date_end =  document.getElementById("date_end").value;
		date_end = date_end.replace('-','');
		date_end = date_end.replace('-','');
		fname_from_cond = fname_from_cond+date_end;
		//alert(fname_from_cond);
	}else{ chkuse_date = "";}

	// check province
	if(document.getElementById("chkuse_prov").checked){
		chkuse_prov =  "1";
	}else{ chkuse_prov = "";}

	if(document.getElementById("chkbox90").checked){
		chkbox90 =  "90";
	}else{ chkbox90 = "";}
	
	if(document.getElementById("chkbox94").checked){
		chkbox94 =  "94";
	}else{ chkbox94 = "";}
	
	if(document.getElementById("chkbox95").checked){
		chkbox95 =  "95";
	}else{ chkbox95 = "";}
	
	if(document.getElementById("chkbox96").checked){
		chkbox96 =  "96";
	}else{ chkbox96 = "";}
	
	if(document.getElementById("chkbox00").checked){
		chkbox00 =  "00";
	}else{ chkbox00 = "";}
	fname_from_cond = fname_from_cond+"_"+chkuse_prov+chkbox90+chkbox94+chkbox95+chkbox96+chkbox00;
	//alert(fname_from_cond);
	//check cause
	if(document.getElementById("chkuse_cause").checked){
		chkuse_cause =  "1";
	}else{ chkuse_cause = "";}
	if(document.getElementById("chkbox_cause1").checked){
		chkbox_cause1 =  ",1";
	}else{ chkbox_cause1 = "";}
	if(document.getElementById("chkbox_cause2").checked){
		chkbox_cause2 =  ",2";
	}else{ chkbox_cause2 = "";}

	if(document.getElementById("chkbox_cause0").checked){
		chkbox_cause0 =  ",3,4,5";
	}else{ chkbox_cause0 = "";}
	fname_from_cond = fname_from_cond+"_"+chkuse_cause+chkbox_cause1+chkbox_cause2+chkbox95+chkbox_cause0;
	//alert(fname_from_cond);
	if(chkuse_cause=="1"){
		cond_cause = chkbox_cause1+chkbox_cause2+chkbox_cause0;
		cond_cause = "("+cond_cause.substring(1)+")";
	}else{ cond_cause = "";}
	
	//check event type
	if(document.getElementById("chkuse_evntyp").checked){
		chkuse_evntyp =  "1";
	}else{ chkuse_evntyp = "";}
	if(document.getElementById("chkbox_evntyp1").checked){
		chkbox_evntyp1 =  ",1";
	}else{ chkbox_evntyp1 = "";}
	if(document.getElementById("chkbox_evntyp2").checked){
		chkbox_evntyp2 =  ",2";
	}else{ chkbox_evntyp2 = "";}
	if(document.getElementById("chkbox_evntyp3").checked){
		chkbox_evntyp3 =  ",3";
	}else{ chkbox_evntyp3 = "";}
	if(document.getElementById("chkbox_evntyp4").checked){
		chkbox_evntyp4 =  ",4";
	}else{ chkbox_evntyp4 = "";}
	fname_from_cond = fname_from_cond+"_"+chkuse_evntyp+chkbox_evntyp1+chkbox_evntyp2+chkbox_evntyp3+chkbox_evntyp4;
//alert(fname_from_cond);

	if(chkuse_evntyp=="1"){
		cond_evntyp = chkbox_evntyp1+chkbox_evntyp2+chkbox_evntyp3+chkbox_evntyp4;
		cond_evntyp = "("+cond_evntyp.substring(1)+")";
	}else{cond_evntyp = "";}
	
	//alert(cond_cause);
	user_type = document.getElementById("user_type").value;
	fname_from_cond = fname_from_cond+"_u"+user_type;
	fname_from_cond = fname_from_cond.replace(/,/g,'');
	fname_from_cond = fname_from_cond+".kml";
	//alert(fname_from_cond);
	if(document.getElementById("dataset1").checked){
		onLoadMapEvent(0,fname_from_cond);
		showNumEvent_Not_latlng();
		
	}else{
		if(document.getElementById("dataset2").checked){
				//onLoadMapVictim();
				setTimeout("MarkingVictim();",2000);
		}else{
				//onLoadMapProject();
				setTimeout("MarkingProject();",2000);
		}
	}
	
}
//  083 195 7844 กะบะห์
// end check for call event, victim or project map
function onLoadMapEvent2(bypass,filename){
if(bypass){
		//onLoad(filename);
	}else{
	var request = GXmlHttp.create();
	//var urlstr="first_timemap_genkml2.php?&OccNumber="+OccNumber+"&occNumber1="+occNumber1+"&occNumber2="+occNumber2+"&occNumber3="+occNumber3+"&occNumber4="+occNumber4+"&chkbox_project="+chkbox_project+"&chkbox_project1="+chkbox_project1+"&chkbox_project2="+chkbox_project2+"&chkbox_project3="+chkbox_project3+"&chkbox_project4="+chkbox_project4+"&chkbox_project5="+chkbox_project5+"&OccProvince="+OccProvince+"&occProvince90="+occProvince90+"&occProvince94="+occProvince94+"&occProvince95="+occProvince95+"&occProvince96="+occProvince96+"&chk_occ="+chk_occ+"&chk_occ1="+chk_occ1+"&chk_occ2="+chk_occ2+"&chk_occ3="+chk_occ3+"&chk_occ4="+chk_occ4+"&chk_occ5="+chk_occ5+"&chk_occ6="+chk_occ6+"&chk_occ7="+chk_occ7+"&fname="+filename;
	var urlstr="first_timemap_genkml3.php?&fname="+filename;

	//alert(urlstr);
	//prompt("urlstr",urlstr);
	request.open('POST', urlstr , true);	// request XML from PHP with AJAX call
	request.onreadystatechange = function () {
	//alert("onreadystatechange="+request.readyState);
	if (request.readyState == 4) {//4 การร้องขอ (request) ให้ผลกลับมาเรียบร้อย
		//var textResponse=request.responseText;
		//var location_leghth = 0;
		//var locations = xmlDoc.documentElement.getElementsByTagName("location");
		//alert(textResponse);
		load();
	    //onLoad(filename); // call time-map function
	}//end if request.readyState == 4
	}// end function1 of onreadystatechange
	request.send(null); //end  function2 of onreadystatechange
	}//by pass
}
 function load() {
   //   if (GBrowserIsCompatible()) {
   //     map = new GMap2(document.getElementById("map"));
   //     map.setCenter(new GLatLng(10.833306, 103.75488), 5);
   //     map.addControl(new GMapTypeControl());
   //     map.addControl(new GLargeMapControl());
   //     // Add KMZ overlay
   //    var geoXml = new GGeoXml("http://110.164.215.167/dsccmis3/first_timemap_genkml3.php?&fname=qaz.kml");
   //    map.addOverlay(geoXml);
   //
   //        geocoder = new GClientGeocoder();
   //   }
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map")); 
		map.addControl(new GLargeMapControl());
		map.setCenter(new GLatLng(41.875696,-87.624207), 11); 
		map.addControl(new GLargeMapControl());
		map.addOverlay(geoXml);
}
    }
function onLoadMapEvent(bypass,filename){//^onLoadMapEvent(0,fname_from_cond);
	if(bypass){
		onLoad(filename);
	}else{
	
   	var request = GXmlHttp.create();
	//alert("test1");
	//ส่วนส่ง้อมูลไป
	var urlstr="first_timemap_genkml.php?chkuse_date="+chkuse_date+"&date_start="+date_start+"&date_end="+date_end+"&chkuse_prov="+chkuse_prov+"&chkbox90="+chkbox90+"&chkbox94="+chkbox94+"&chkbox95="+chkbox95+"&chkbox96="+chkbox96+"&chkbox00="+chkbox00+"&cond_cause="+cond_cause+"&cond_evntyp="+cond_evntyp+"&user_type="+user_type+"&fname="+filename;
	//alert(urlstr);
	//prompt("urlstr",urlstr);
	request.open('POST', urlstr , true);	// request XML from PHP with AJAX call
	request.onreadystatechange = function () {
	//alert("onreadystatechange="+request.readyState);
	if (request.readyState == 4) {//4 การร้องขอ (request) ให้ผลกลับมาเรียบร้อย
		//var textResponse=request.responseText;
		//var location_leghth = 0;
		//var locations = xmlDoc.documentElement.getElementsByTagName("location");
		//alert(textResponse);
	    onLoad(filename); // call time-map function
	}//end if request.readyState == 4
	}// end function1 of onreadystatechange
	request.send(null); //end  function2 of onreadystatechange
	}//by pass
}

function showNumEvent_Not_latlng(){
   	var request = GXmlHttp.create();
	//alert("create resuet");
	// get num event whict lat null or lng null
	var urlstr="first_timemap_numevent.php?chkuse_date="+chkuse_date+"&date_start="+date_start+"&date_end="+date_end+"&chkuse_prov="+chkuse_prov+"&chkbox90="+chkbox90+"&chkbox94="+chkbox94+"&chkbox95="+chkbox95+"&chkbox96="+chkbox96+"&chkbox00="+chkbox00+"&cond_cause="+cond_cause+"&cond_evntyp="+cond_evntyp+"&user_type="+user_type;
	//alert(urlstr);
	request.open('POST', urlstr , true);	// request XML from PHP with AJAX call
	request.onreadystatechange = function () {
	//alert("onreadystatechange="+request.readyState);
	if (request.readyState == 4) {
		var textResponse=request.responseText;
		document.getElementById("numevent_all").innerHTML = "<font color=blue>ผลการค้นหา "+textResponse+" เหตุการณ์</font>";

	}//end if request.readyState == 4
	}// end function1 of onreadystatechange
	request.send(null); //end  function2 of onreadystatechange

}
//------------------------------------------------------------------

//------------------------ Victim map -----------------------------
function MarkingVictim(){
document.getElementById("numevent_all").innerHTML = "";
document.getElementById("numevent").innerHTML = "";
			document.getElementById("timemap").innerHTML = "<div id=\"mapcontainer\"><div id=\"map\"></div></div>";
			map = new GMap(document.getElementById("map"));
			map.addControl(new GLargeMapControl());
 			//map.addControl(new GLargeMapControl3D());
     		map.addControl(new GMapTypeControl());
	 		map.setCenter(new GLatLng(13.785447,100.590976),6, G_NORMAL_MAP);
     getMarkers();
     
     GEvent.addListener(map, "click", function(overlay, point) {
		      if (overlay){	// marker clicked
			      overlay.openInfoWindowHtml(overlay.infowindow);	// open InfoWindow
		      } else if (point) {	// background clicked
			      
		      }
	      });
		  //add by somsawat
		 /* GEvent.addListener(map,'zoomend',function() {
				getMarkers();
			});
 
			GEvent.addListener(map,'moveend',function() {
				getMarkers();
			});*/
		  //end,,,,,,,,,,,,,,,,,,,,,,,,
}
function MarkingVictim2(){
document.getElementById("numevent_all").innerHTML = "";
document.getElementById("numevent").innerHTML = "";
			document.getElementById("timemap").innerHTML = "<div id=\"mapcontainer\"><div id=\"map\"></div></div>";
			map = new GMap(document.getElementById("map"));
			map.addControl(new GLargeMapControl());
 			//map.addControl(new GLargeMapControl3D());
     		map.addControl(new GMapTypeControl());
	 		map.setCenter(new GLatLng(13.785447,100.590976),6, G_NORMAL_MAP);
     getMarkers();
     
     GEvent.addListener(map, "click", function(overlay, point) {
		      if (overlay){	// marker clicked
			      overlay.openInfoWindowHtml(overlay.infowindow);	// open InfoWindow
		      } else if (point) {	// background clicked
			      
		      }
	      });
		  //add by somsawat
		 /* GEvent.addListener(map,'zoomend',function() {
				getMarkers();
			});
 
			GEvent.addListener(map,'moveend',function() {
				getMarkers();
			});*/
		  //end,,,,,,,,,,,,,,,,,,,,,,,,
}

function getMarkers2(){
	var urlstr="readVictim.php";
	var request = GXmlHttp.create();
	var numvic_all = 0;
	var numvic_have_latlng=0;
	var numvill_have_latlng=0;
	var lat,lng;
	urlstr = urlstr+"?chkuse_date="+chkuse_date+"&date_start="+date_start+"&date_end="+date_end+"&chkuse_prov="+chkuse_prov+"&chkbox90="+chkbox90+"&chkbox94="+chkbox94+"&chkbox95="+chkbox95+"&chkbox96="+chkbox96+"&chkbox00="+chkbox00+"&cond_cause="+cond_cause+"&cond_evntyp="+cond_evntyp+"&user_type="+user_type;
	//urlstr = urlstr+"?top="+mapTop+"&bottom="+mapBottom+"&left="+mapLeft+"&right="+mapRight+"&prov=";
	//alert(urlstr);
    request.open('GET', urlstr , true);	// request XML from PHP with AJAX call
    request.onreadystatechange = function () {
	if (request.readyState == 4) {
		var xmlDoc = request.responseXML;
		locations = xmlDoc.documentElement.getElementsByTagName("location");
		markers = [];
		//alert("ค้นพบจำนวน "+locations.length+" หมู่บ้าน");
		//document.getElementById("numevent").innerHTML = "ผลการค้นหา "+locations.length+" หมู่บ้าน";
		//alert("markers len="+markers.length);
		if (locations.length){
			for (var i = 0; i < locations.length; i++) { // cycle thru locations
				//change icon------
				var Icon = new GIcon(); 
				//if(locations[i].getAttribute("losbody")=="4"){
					//Icon.image = "test.ico"; 
					//Icon.image = "user_male.png"; 
				//}else{
					//Icon.image = "testyel.ico"; 
					Icon.image = "iconfile/circle_red.png";
				//}
				var numvictim;
				var sizexy;;
				numvictim = locations[i].getAttribute("numvic");
				numvic_all = numvic_all + numvictim*1;
				if(numvictim == 1){
					sizexy = 6;
				}else{
					if(numvictim <= 5){
						sizexy = 9;
					}else{
						if(numvictim <= 10){
							sizexy = 11;
						}else{
							if(numvictim <= 15){
								sizexy = 13;
							}else{
								if(numvictim <= 20){
									sizexy = 15;
								}else{
									sizexy = 18;
								}
							}
						}
					}
				}
				Icon.iconSize = new GSize(sizexy, sizexy); 
				//Icon.iconSize = new GSize(numvictim*1, numvictim*1); 
				//Icon.shadow = "myshadow.png"; 
				//Icon.shadowSize = new GSize(36, 34); 
				Icon.iconAnchor = new GPoint(8, 16); 
				Icon.infoWindowAnchor = new GPoint(8,1); 
				//Icon.transparent = "mytran.png";	//Icon.imageMap=[9,0,6,1,4,2,2,4,0,8,0,12,1,14,2,16,5,19,7,23,8,26,9,30,9,34,11,34,11,30,12,26,13,24,14,21,16,18,18,16,20,12,20,8,18,4,16,2,15,1,13,0]; 
				//Icon.printImage = "mymarkerie.gif"; 
				//Icon.mozPrintImage = "mymarkerff.gif"; 
				//Icon.printShadow = "myshadow.gif";
				//----end change icon
				lat=locations[i].getAttribute("lat");
				lng=locations[i].getAttribute("lng");
				if(lat != "" && lng != ""){
					numvill_have_latlng = numvill_have_latlng+1;
					numvic_have_latlng = numvic_have_latlng +numvictim*1;
					markers[i] = new GMarker(new GLatLng(lat,lng), {icon: Icon});
					// Add attributes to the marker so we can poll them later.
					// When clicked, an overlay will have these properties.
					markers[i].infowindow = "<b>"+locations[i].getAttribute("vill_name")+"</b>"+"("+locations[i].getAttribute("id")+")"+" "+locations[i].getAttribute("tam_name")+" "+locations[i].getAttribute("amp_name")+" "+locations[i].getAttribute("prov_name")+"<br>มีผู้ได้รับผลกระทบจำนวน "+locations[i].getAttribute("numvic")+" คน"+locations[i].getAttribute("list_victim");
							
					// Useful things to store on a marker (Not needed for this example, could be removed)
					// Tells you what index in the markers[] array an overlay is
					markers[i].markerindex = i;
					// Store the location_id of the location the marker represents.
					// Very useful to know the true id of a marker, you could then make
					// AJAX calls to the database to update the information if you had it's location_id
					markers[i].db_id = locations[i].getAttribute("location_id");
					map.addOverlay(markers[i]);
				}
			}//end for
		}//end if locations.length
		document.getElementById("numevent_all").innerHTML = "<font color=blue>ผลการค้นหา "+locations.length+" พื้นที่ ("+numvic_all+" คน )</font>";
		document.getElementById("numevent").innerHTML = "<font color=blue>ปรากฏข้อมูลพิกัด "+numvill_have_latlng+" พื้นที่ ("+numvic_have_latlng+" คน)</font>";
	   }//end if request.readyState == 4
	}// end function1 of onreadystatechange
	request.send(null); //end  function2 of onreadystatechange
}
function getMarkers(){
	var urlstr="readVictim.php";
	var request = GXmlHttp.create();
	var numvic_all = 0;
	var numvic_have_latlng=0;
	var numvill_have_latlng=0;
	var lat,lng;
	urlstr = urlstr+"?chkuse_date="+chkuse_date+"&date_start="+date_start+"&date_end="+date_end+"&chkuse_prov="+chkuse_prov+"&chkbox90="+chkbox90+"&chkbox94="+chkbox94+"&chkbox95="+chkbox95+"&chkbox96="+chkbox96+"&chkbox00="+chkbox00+"&cond_cause="+cond_cause+"&cond_evntyp="+cond_evntyp+"&user_type="+user_type;
	//urlstr = urlstr+"?top="+mapTop+"&bottom="+mapBottom+"&left="+mapLeft+"&right="+mapRight+"&prov=";
	//alert(urlstr);
    request.open('GET', urlstr , true);	// request XML from PHP with AJAX call
    request.onreadystatechange = function () {
	if (request.readyState == 4) {
		var xmlDoc = request.responseXML;
		locations = xmlDoc.documentElement.getElementsByTagName("location");
		markers = [];
		//alert("ค้นพบจำนวน "+locations.length+" หมู่บ้าน");
		//document.getElementById("numevent").innerHTML = "ผลการค้นหา "+locations.length+" หมู่บ้าน";
		//alert("markers len="+markers.length);
		if (locations.length){
			for (var i = 0; i < locations.length; i++) { // cycle thru locations
				//change icon------
				var Icon = new GIcon(); 
				//if(locations[i].getAttribute("losbody")=="4"){
					//Icon.image = "test.ico"; 
					//Icon.image = "user_male.png"; 
				//}else{
					//Icon.image = "testyel.ico"; 
					Icon.image = "iconfile/circle_red.png";
				//}
				var numvictim;
				var sizexy;;
				numvictim = locations[i].getAttribute("numvic");
				numvic_all = numvic_all + numvictim*1;
				if(numvictim == 1){
					sizexy = 6;
				}else{
					if(numvictim <= 5){
						sizexy = 9;
					}else{
						if(numvictim <= 10){
							sizexy = 11;
						}else{
							if(numvictim <= 15){
								sizexy = 13;
							}else{
								if(numvictim <= 20){
									sizexy = 15;
								}else{
									sizexy = 18;
								}
							}
						}
					}
				}
				Icon.iconSize = new GSize(sizexy, sizexy); 
				//Icon.iconSize = new GSize(numvictim*1, numvictim*1); 
				//Icon.shadow = "myshadow.png"; 
				//Icon.shadowSize = new GSize(36, 34); 
				Icon.iconAnchor = new GPoint(8, 16); 
				Icon.infoWindowAnchor = new GPoint(8,1); 
				//Icon.transparent = "mytran.png";	//Icon.imageMap=[9,0,6,1,4,2,2,4,0,8,0,12,1,14,2,16,5,19,7,23,8,26,9,30,9,34,11,34,11,30,12,26,13,24,14,21,16,18,18,16,20,12,20,8,18,4,16,2,15,1,13,0]; 
				//Icon.printImage = "mymarkerie.gif"; 
				//Icon.mozPrintImage = "mymarkerff.gif"; 
				//Icon.printShadow = "myshadow.gif";
				//----end change icon
				lat=locations[i].getAttribute("lat");
				lng=locations[i].getAttribute("lng");
				if(lat != "" && lng != ""){
					numvill_have_latlng = numvill_have_latlng+1;
					numvic_have_latlng = numvic_have_latlng +numvictim*1;
					markers[i] = new GMarker(new GLatLng(lat,lng), {icon: Icon});
					// Add attributes to the marker so we can poll them later.
					// When clicked, an overlay will have these properties.
					markers[i].infowindow = "<b>"+locations[i].getAttribute("vill_name")+"</b>"+"("+locations[i].getAttribute("id")+")"+" "+locations[i].getAttribute("tam_name")+" "+locations[i].getAttribute("amp_name")+" "+locations[i].getAttribute("prov_name")+"<br>มีผู้ได้รับผลกระทบจำนวน "+locations[i].getAttribute("numvic")+" คน"+locations[i].getAttribute("list_victim");
							
					// Useful things to store on a marker (Not needed for this example, could be removed)
					// Tells you what index in the markers[] array an overlay is
					markers[i].markerindex = i;
					// Store the location_id of the location the marker represents.
					// Very useful to know the true id of a marker, you could then make
					// AJAX calls to the database to update the information if you had it's location_id
					markers[i].db_id = locations[i].getAttribute("location_id");
					map.addOverlay(markers[i]);
				}
			}//end for
		}//end if locations.length
		document.getElementById("numevent_all").innerHTML = "<font color=blue>ผลการค้นหา "+locations.length+" พื้นที่ ("+numvic_all+" คน )</font>";
		document.getElementById("numevent").innerHTML = "<font color=blue>ปรากฏข้อมูลพิกัด "+numvill_have_latlng+" พื้นที่ ("+numvic_have_latlng+" คน)</font>";
	   }//end if request.readyState == 4
	}// end function1 of onreadystatechange
	request.send(null); //end  function2 of onreadystatechange
}
		
		//]]>
//---------------------------------------------------------------------------------
// end Victim  map --------------------------------------------

//---------------------------------- Project map ---------------------
function MarkingProject(){
     getMarkersProject();
     GEvent.addListener(map, "click", function(overlay, point) {
	 if (overlay){	// marker clicked
		overlay.openInfoWindowHtml(overlay.infowindow);	// open InfoWindow
	 } else if (point) {	// background clicked
			      
		    }
	 });
}

function getMarkersProject(){
	//alert("1");
	var urlstr="readProject.php";
	var request = GXmlHttp.create();
	//alert("2");
    request.open('GET', urlstr , true);	// request XML from PHP with AJAX call
    request.onreadystatechange = function () {
	if (request.readyState == 4) {
		var xmlDoc = request.responseXML;
		locations = xmlDoc.documentElement.getElementsByTagName("location");
		markers = [];
		//alert("ค้นพบจำนวน "+locations.length+" พื้นที่");
		//alert("markers len="+markers.length);
		if (locations.length){
			for (var i = 0; i < locations.length; i++) { // cycle thru locations
				//change icon------
				var Icon = new GIcon(); 
				Icon.image = "iconfile/circle_red.png";
				var sumoffund;
				var sizexy;;
				sumoffund = locations[i].getAttribute("sumoffund");
				sizexy = (sumoffund*1)+2;
				Icon.iconSize = new GSize(sizexy, sizexy); 
				Icon.iconAnchor = new GPoint(8, 16); 
				Icon.infoWindowAnchor = new GPoint(8,1); 
				markers[i] = new GMarker(new GLatLng(locations[i].getAttribute("lat"),locations[i].getAttribute("lng")), {icon: Icon});
				// Add attributes to the marker so we can poll them later.
				// When clicked, an overlay will have these properties.
				markers[i].infowindow = "<b>"+locations[i].getAttribute("vill_name")+"</b>"+"("+locations[i].getAttribute("id")+")"+" "+locations[i].getAttribute("tam_name")+" "+locations[i].getAttribute("amp_name")+" "+locations[i].getAttribute("prov_name")+"<br>มีโครงการทั้งหมด "+locations[i].getAttribute("sumoffund")+" โครงการ";
							
				// Useful things to store on a marker (Not needed for this example, could be removed)
				// Tells you what index in the markers[] array an overlay is
				markers[i].markerindex = i;
				// Store the location_id of the location the marker represents.
				// Very useful to know the true id of a marker, you could then make
				// AJAX calls to the database to update the information if you had it's location_id
				markers[i].db_id = locations[i].getAttribute("location_id");
				map.addOverlay(markers[i]);
			}//end for
		}//end if locations.length
	   }//end if request.readyState == 4
	}// end function1 of onreadystatechange
	request.send(null); //end  function2 of onreadystatechange
}
		
// end Project map ---------------------------------------------------

//call calendar ----------------------
//start calender ------------------
function getCalendar(in_dateField) 
{
    if (calendarWindow && !calendarWindow.closed) {
       // alert('Calendar window already open.  Attempting focus...');
        try {
            calendarWindow.focus();
        }
        catch(e) {}
        
        return false;
    }

    var cal_width = 415;
    var cal_height = 310;

    // IE needs less space to make this thing
    if ((document.all) && (navigator.userAgent.indexOf("Konqueror") == -1)) {
        cal_width = 410;
    }

    calendarTarget = in_dateField;
    calendarWindow = window.open('calendar.html', 'dateSelectorPopup','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=0,dependent=no,width='+cal_width+',height='+cal_height + (calendarScreenX != 'auto' ? ',screenX=' + calendarScreenX : '') + (calendarScreenY != 'auto' ? ',screenY=' + calendarScreenY : ''));

    return false;
}

// {{{ killCalendar()

function killCalendar() 
{
    if (calendarWindow && !calendarWindow.closed) {
        calendarWindow.close();
    }
}

// }}}
//---------------------------------
var calendarWindow = null;
var calendarColors = new Array();
calendarColors['bgColor'] = '#BDC5D0';
calendarColors['borderColor'] = '#333366';
calendarColors['headerBgColor'] = '#143464';
calendarColors['headerColor'] = '#FFFFFF';
calendarColors['dateBgColor'] = '#8493A8';
calendarColors['dateColor'] = '#004080';
calendarColors['dateHoverBgColor'] = '#FFFFFF';
calendarColors['dateHoverColor'] = '#8493A8';
var calendarMonths = new Array('มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม');
var calendarWeekdays = new Array('S', 'M', 'T', 'W', 'T', 'F', 'S', 'S');
var calendarUseToday = true;
var calendarFormat = 'y/m/d';
var calendarStartMonday = true;
var calendarScreenX = 100; // either 'auto' or numeric
var calendarScreenY = 100; // either 'auto' or numeric

//---------------------------------------
</script>
<form name="formcondition" id="formcondition">
<table width="1000" border="0" align="left" cellspacing="0">
      <tr valign="top">
        <td height="35" colspan="2">	<strong>เลือกชุดข้อมูล:</strong> <input name="dataset" id="dataset1" type="radio" value="1" checked="checked" onclick="ShowHiddenCondition(1);"/>
                      เหตุการณ์ 
       <input name="dataset" id="dataset2" type="radio" value="2" onclick="ShowHiddenCondition(2);"/>
ผู้ได้รับผลกระทบ
<input name="dataset" id="dataset3" type="radio" value="3"  onclick="ShowHiddenCondition(3);"/>
การเยียวยาประชาชน
</td>
      </tr>
      <tr valign="top">
        <td width="227"><table border="0">
          <tr>
            <td>
				<!--insert div-->
				<div id="cond_case3" style="display:none" >
				
				<table border="0" cellspacing="0" width="220">
                  <tr>
                    <td colspan="2"><input name="user_type" id="user_type" type="hidden" value="<?=$user_type?>" /></td>
                  </tr>
                  <!--<tr>
                    <td colspan="2"><input name="chkbox_project" type="checkbox" id="chkbox_project" value="1" onchange="changeUseCause2()"/>
                      <strong>ประแหล่งทุน</strong></td>
                  </tr>
                  <tr>
                   <!-- <td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="chkbox_project1" type="checkbox" id="chkbox_project1" value="1" disabled="disabled"/>
                      โครงการอาชีพ ศวชต.ปัตตานี</td>
                  </tr>
                  <tr>
                    <td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="chkbox_project2" type="checkbox" id="chkbox_project2" value="มยส.(งบ สสส.)"  disabled="disabled"/>
                                       มยส.(งบ สสส.)</td>
 </tr>
                  <tr>
                    <td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="chkbox_project3" type="checkbox" id="chkbox_project3" value="มยส.(งบ EU2)"  disabled="disabled"/>
                      มยส.(งบ EU2)</td>
                  </tr>
				  <tr>
                    <td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="chkbox_project4" type="checkbox" id="chkbox_project4" value="กองทุนแม่"  disabled="disabled"/>
                      กองทุนแม่</td>
                  </tr>
				  <tr>
                    <td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="chkbox_project5" type="checkbox" id="chkbox_project5" value="มูลนิธิเครือข่ายผู้หญิงยุติความรุนแรง"  disabled="disabled"/>
                      มูลนิธิเครือข่ายผู้หญิงยุติความรุนแรง</td>
                  </tr>
				  -->
                  <!---
				  <tr>
                    <td colspan="2">&nbsp;</td>
                  </tr>
                  <tr>
                    <td colspan="2"><input name="chk_occ" type="checkbox" id="chk_occ" value="1" onchange="occType()"/>
                      <strong>อาชีพ</strong></td>
                  </tr>
                  <tr>
                    <td colspan="2"><table>
                      <tr>
                          <td>&nbsp;&nbsp;&nbsp;
                            <input name="chk_occ1" type="checkbox" id="chk_occ1" value="1" disabled="disabled"/>
ขายอาหาร </td>
                          <td><input name="chk_occ2" type="checkbox" id="chk_occ2" value="2" disabled="disabled"/>
                        ขายของชำ </td>
                      </tr>
                        <tr>
                          <td>&nbsp;&nbsp;&nbsp;
                            <input name="chk_occ3" type="checkbox" id="chk_occ3" value="3" disabled="disabled"/>
                            ตัดเย็บ</td>
                          <td><input name="chk_occ4" type="checkbox" id="chk_occ4" value="4" disabled="disabled"/> 
                            เลี้ยงสัตว์</td>
                        </tr>
						<tr>
                          <td>&nbsp;&nbsp;&nbsp;
                            <input name="chk_occ5" type="checkbox" id="chk_occ5" value="3" disabled="disabled"/>
                            ทำสวน/ปลูกผัก</td>
                          <td><input name="chk_occ6" type="checkbox" id="chk_occ6" value="4" disabled="disabled"/> 
                            ร้านเสริมสวย</td>
                        </tr>
						<tr>
                          <td>&nbsp;&nbsp;&nbsp;
                            <input name="chk_occ7" type="checkbox" id="chk_occ7" value="3" disabled="disabled"/>
                            อื่น ๆ</td>
                          <td>&nbsp;</td>
                        </tr>
                      </table>                    </td>
                  </tr>
                  <tr>
                    <td colspan="2">&nbsp;</td>
                  </tr>
                  <td colspan="2"><input name="OccNumber" type="checkbox" id="OccNumber" value="1"  onchange="occNumber()" />
                    <strong> ปีรับทุน</strong></td>
                  </tr>
                  <tr>
                    <td>&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="occNumber1" type="checkbox" id="occNumber1" value="90" disabled="disabled"  />
                      ครั้งที่ 1</td>
                   <td><input name="occNumber2" type="checkbox" id="occNumber2" value="94" disabled="disabled" />
                    ครั้งที่ 2</td>
                  </tr>
                  <tr>
                    <td>&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="occNumber3" type="checkbox" id="occNumber3" value="95" disabled="disabled"/>
                      ครั้งที่ 3</td>
                    <td><input name="occNumber4" type="checkbox" id="occNumber4" value="96" disabled="disabled"/>
                    ครั้งที่ 4</td>
                    </tr>
                    <tr>
                    <td colspan="2">&nbsp;</td>
                  </tr>
				  -->
                  <tr>
                    <td colspan="2">
                      <strong>ภูมิลำเนา</strong></td>
                  </tr>
                  <tr>
                    <td>&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="occProvince90" type="checkbox" id="occProvince90" value="90"  />
                      สงขลา</td>
                    <td><input name="occProvince94" type="checkbox" id="occProvince94" value="94"   />
                      ปัตตานี</td>
                  </tr>
                  <tr>
                    <td>&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="occProvince95" type="checkbox" id="occProvince95" value="95"  />
                      ยะลา</td>
                    <td><input name="occProvince96" type="checkbox" id="occProvince96" value="96" />
                      นราธิวาส</td>
                  </tr>
				  <tr>
                    <td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="occProvince00" type="checkbox" id="occProvince00" value="00" />
                      นอกพื้นที่ 4 จังหวัด </td>
                  </tr>
                
                  <tr>
                    <td colspan="2">&nbsp;</td>
                  </tr>
             
				 <!--tr>
                    <td colspan="2"><strong>เลือกชุดข้อมูล</strong></td>
                  </tr>
                  <tr>
                    <td colspan="2"><input name="chkbox_show_event" type="checkbox" id="chkbox_show_event" value="1" />
                        <strong>เหตุการณ์ฯ</strong></td>
                  </tr>
                  <tr>
                    <td>ประเภท</td>
                    <td><input name="chkbox_type1" type="checkbox" id="chkbox_type1" value="1" />
                      วางระเบิด
                      <input name="chkbox_type2" type="checkbox" id="chkbox_type2" value="2" />
                      ยิง <br />
                      <input name="chkbox_type3" type="checkbox" id="chkbox_type3" value="3" />
                      วางเพลิง
                      <input name="chkbox_type4" type="checkbox" id="chkbox_type4" value="4" />
                      อื่นๆ<br />
                      <input name="chkbox_type9" type="checkbox" id="chkbox_type9" value="9" />
                      ไม่ระบุ</td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td colspan="2"><input name="chkbox_show_victim" type="checkbox" id="chkbox_show_victim" value="1" />
                        <strong>ผู้ได้รับผลกระทบ</strong></td>
                  </tr>
                  <tr>
                    <td>การบาดเจ็บ</td>
                    <td><input name="chkbox_inj1" type="checkbox" id="chkbox_inj1" value="1" />
                      บาดเจ็บ
                      <input name="chkbox_inj2" type="checkbox" id="chkbox_inj2" value="2" />
                      เสียชีวิต</td>
                  </tr>
                  <tr>
                    <td>เพศ</td>
                    <td><input name="chkbox_sex1" type="checkbox" id="chkbox_sex1" value="1" />
                      ชาย
                      <input name="chkbox_sex2" type="checkbox" id="chkbox_sex2" value="2" />
                      หญิง</td>
                  </tr>
                  <tr>
                    <td>ศาสนา</td>
                    <td><input name="chkbox_reg1" type="checkbox" id="chkbox_reg1" value="1" />
                      พุทธ
                      <input name="chkbox_reg2" type="checkbox" id="chkbox_reg2" value="2" />
                      คริสต์ <br />
                      <input name="chkbox_reg3" type="checkbox" id="chkbox_reg3" value="3" />
                      อิสลาม
                      <input name="chkbox_reg4" type="checkbox" id="chkbox_reg4" value="4" />
                      อื่นๆ </td>
                  </tr-->
              
			  <tr>
                    <td colspan="2"><div align="center">
                        <input type="button" name="Submit3" value="ตกลง" onclick="javascript:checkDataset2();"/>
                        <input type="reset" name="Submit4" value="ยกเลิก" />
                    </div></td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td colspan="2"><div id="numevent_all2" align="center"></div></td>
                  </tr>
                  <tr>
                    <td colspan="2"><div id="numevent2" align="center"></div></td>
                  </tr>
                  <tr>
                    <td colspan="2"><br /><div id="last_update2" align="center" style="color:green"></div></td>
                  </tr>
                </table>
			 
			 </div>
				 
				 <div id="cond_case12">
                <table border="0" cellspacing="0" width="220">
                  <tr>
                    <td colspan="2"><input name="user_type" id="user_type" type="hidden" value="<?=$user_type?>" /></td>
                  </tr>
                  <tr>
                    <td colspan="2"><input name="chkuse_cause" type="checkbox" id="chkuse_cause" value="1" onchange="changeUseCause()"/>
                        <strong>สาเหตุของเหตุการณ์ฯ</strong></td>
                  </tr>
                  <tr>
                    <td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="chkbox_cause1" type="checkbox" id="chkbox_cause1" value="1" disabled="disabled"/>
                      ความไม่สงบ</td>
                  </tr>
                  <tr>
                    <td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="chkbox_cause2" type="checkbox" id="chkbox_cause2" value="2"  disabled="disabled"/>
                      อยู่ระหว่างตรวจสอบ</td>
                  </tr>
                  <tr>
                    <td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="chkbox_cause0" type="checkbox" id="chkbox_cause0" value="3 4 5 9"  disabled="disabled"/>
                      อื่นๆ (ส่วนตัว อุบัติเหตุ ไม่ระบุ) </td>
                  </tr>
                  <tr>
                    <td colspan="2">&nbsp;</td>
                  </tr>
                  <tr>
                    <td colspan="2"><input name="chkuse_evntyp" type="checkbox" id="chkuse_evntyp" value="1" onchange="changeUseType()"/>
                      <strong>ประเภทเหตุการณ์ฯ</strong></td>
                  </tr>
                  <tr>
                    <td colspan="2"><table>
                      <tr>
                          <td>&nbsp;&nbsp;&nbsp;
                            <input name="chkbox_evntyp1" type="checkbox" id="chkbox_evntyp1" value="1" disabled="disabled"/>
ระเบิด </td>
                          <td><input name="chkbox_evntyp2" type="checkbox" id="chkbox_evntyp2" value="2" disabled="disabled"/>
                        ยิง </td>
                      </tr>
                        <tr>
                          <td>&nbsp;&nbsp;&nbsp;
                            <input name="chkbox_evntyp3" type="checkbox" id="chkbox_evntyp3" value="3" disabled="disabled"/> 
                            วางเพลิง </td>
                          <td><input name="chkbox_evntyp4" type="checkbox" id="chkbox_evntyp4" value="4" disabled="disabled"/> 
                            อื่นๆ </td>
                        </tr>
                      </table>                    </td>
                  </tr>
                  <tr>
                    <td colspan="2">&nbsp;</td>
                  </tr>
                  <tr>
                    <td colspan="2"><strong>
                      <input name="chkuse_date" type="checkbox" id="chkuse_date" value="1" checked="checked" />
                      <strong>ช่วงเวลา</strong></strong></td>
                  </tr>
                  <tr>
                    <td>&nbsp;&nbsp;&nbsp;&nbsp;ตั้งแต่วันที่</td>
                    <td><input name="date_start" type="text" id="date_start" value="2551-01-01" size="10" />
                    <a href="#" onclick="return getCalendar(document.forms[0].date_start);"><img src="images/calendar.png" border="0" /></a></td>
                  </tr>
                  <tr>
                    <td>&nbsp;&nbsp;&nbsp;&nbsp;ถึงวันที่</td>
                    <td><input name="date_end" type="text" id="date_end" value="2551-02-01" size="10" />
                    <a href="#" onclick="return getCalendar(document.forms[0].date_end);"><img src="images/calendar.png" border="0" /></a></td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td colspan="2"><input name="chkuse_prov" type="checkbox" id="chkuse_prov" value="1" checked="checked" onchange="changeUseProv()" /><strong><font id="addr_type">ที่เกิดเหตุ / ภูมิลำเนา</font></strong> </td>
                  </tr>
                  <tr>
                    <td>&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="chkbox90" type="checkbox" id="chkbox90" value="90" checked="checked" />
                      สงขลา</td>
                    <td><input name="chkbox94" type="checkbox" id="chkbox94" value="94" checked="checked" />
                      ปัตตานี</td>
                  </tr>
                  <tr>
                    <td>&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="chkbox95" type="checkbox" id="chkbox95" value="95" />
                      ยะลา</td>
                    <td><input name="chkbox96" type="checkbox" id="chkbox96" value="96"/>
                      นราธิวาส</td>
                  </tr>
                  <tr>
                    <td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="chkbox00" type="checkbox" id="chkbox00" value="00" />
                      นอกพื้นที่ 4 จังหวัด </td>
                  </tr>
                  <tr>
                    <td colspan="2">&nbsp;</td>
                  </tr>
                  <!--tr>
                    <td colspan="2"><strong>เลือกชุดข้อมูล</strong></td>
                  </tr>
                  <tr>
                    <td colspan="2"><input name="chkbox_show_event" type="checkbox" id="chkbox_show_event" value="1" />
                        <strong>เหตุการณ์ฯ</strong></td>
                  </tr>
                  <tr>
                    <td>ประเภท</td>
                    <td><input name="chkbox_type1" type="checkbox" id="chkbox_type1" value="1" />
                      วางระเบิด
                      <input name="chkbox_type2" type="checkbox" id="chkbox_type2" value="2" />
                      ยิง <br />
                      <input name="chkbox_type3" type="checkbox" id="chkbox_type3" value="3" />
                      วางเพลิง
                      <input name="chkbox_type4" type="checkbox" id="chkbox_type4" value="4" />
                      อื่นๆ<br />
                      <input name="chkbox_type9" type="checkbox" id="chkbox_type9" value="9" />
                      ไม่ระบุ</td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td colspan="2"><input name="chkbox_show_victim" type="checkbox" id="chkbox_show_victim" value="1" />
                        <strong>ผู้ได้รับผลกระทบ</strong></td>
                  </tr>
                  <tr>
                    <td>การบาดเจ็บ</td>
                    <td><input name="chkbox_inj1" type="checkbox" id="chkbox_inj1" value="1" />
                      บาดเจ็บ
                      <input name="chkbox_inj2" type="checkbox" id="chkbox_inj2" value="2" />
                      เสียชีวิต</td>
                  </tr>
                  <tr>
                    <td>เพศ</td>
                    <td><input name="chkbox_sex1" type="checkbox" id="chkbox_sex1" value="1" />
                      ชาย
                      <input name="chkbox_sex2" type="checkbox" id="chkbox_sex2" value="2" />
                      หญิง</td>
                  </tr>
                  <tr>
                    <td>ศาสนา</td>
                    <td><input name="chkbox_reg1" type="checkbox" id="chkbox_reg1" value="1" />
                      พุทธ
                      <input name="chkbox_reg2" type="checkbox" id="chkbox_reg2" value="2" />
                      คริสต์ <br />
                      <input name="chkbox_reg3" type="checkbox" id="chkbox_reg3" value="3" />
                      อิสลาม
                      <input name="chkbox_reg4" type="checkbox" id="chkbox_reg4" value="4" />
                      อื่นๆ </td>
                  </tr-->
                  <tr>
                    <td colspan="2"><div align="center">
                        <input type="button" name="Submit3" value="ตกลง" onclick="javascript:checkDataset();"/>
                        <input type="reset" name="Submit4" value="ยกเลิก" />
                    </div></td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td colspan="2"><div id="numevent_all" align="center"></div></td>
                  </tr>
                  <tr>
                    <td colspan="2"><div id="numevent" align="center"></div></td>
                  </tr>
                  <tr>
                    <td colspan="2"><br /><div id="last_update" align="center" style="color:green"></div></td>
                  </tr>
                </table>
				 </div>
				  <!-- end insert div-->
            </td>
          </tr>
        </table>
		
		
		
		</td>
        <td width="746"><table width="100%" border="0">
          <tr valign="top">
            <td><div id="timemap">
        <div id="timelinecontainer">
          <div id="timeline"></div>
        </div>
        <div id="mapcontainer">
          <div id="map"></div>
        </div>
    </div>			</td>
          </tr>
        </table></td>
      </tr>
</table>
</form>	  
<script>
	ShowHiddenCondition(1);
</script>